package com.budwk.app.sqfwV2.generator.meeting;

import com.budwk.app.sqfwDoc.codeGenerator.cusType.SqfwImage;
import com.budwk.app.sqfwDoc.codeGenerator.pdfGenerate.BaseTemplatePdfGenerator;
import com.budwk.app.sqfwDoc.codeGenerator.pdfGenerate.SqfwPdfCreateCommonBO;
import com.budwk.app.sqfwV2.dto.MeetingParamDTO;
import com.budwk.app.util.poiUtils.CommonFormOfficeUtils;
import com.deepoove.poi.data.PictureRenderData;
import org.apache.commons.compress.utils.Lists;

import java.util.List;
import java.util.Map;

/**
 * 本代码由代码生成器生成，版本号1.0
 */
public class MeetingPdfGenerator extends BaseTemplatePdfGenerator {

    private String templateName;


    public MeetingPdfGenerator() {
    }

    public MeetingPdfGenerator(String templateName) {
        this.templateName = templateName;
    }


    /**
     * 判断使用使用这个generator生成pdf
     *
     * @param pdfDTO 创建pdf数据素材
     * @return 结果
     */
    @Override
    public boolean pdfCreateConditionCheck(SqfwPdfCreateCommonBO pdfDTO) {
        return true;
    }

    @Override
    public void customerPopularPdfParam(Map<String, Object> paramMap, SqfwPdfCreateCommonBO pdfParamBO) {
        MeetingParamDTO meetingParamDTO = (MeetingParamDTO) pdfParamBO.getAbstractCustomerPdfCreateField();
        SqfwImage images = meetingParamDTO.getImages();
        List<String> pictureUrlList = images.getImageUrlList();
        if (pictureUrlList.isEmpty()) {
            paramMap.put("imagess", Lists.newArrayList());

        } else {
            if(pictureUrlList.size()>3) pictureUrlList=pictureUrlList.subList(0,3);
            List<Map<String, PictureRenderData>> pictures = CommonFormOfficeUtils.addWordPicture(pictureUrlList, "images", 5F);
            paramMap.put("imagess", pictures);
        }

    }

    @Override
    public String getTemplateName() {
        return templateName;
    }


    public void setTemplateName(String templateName) {
        this.templateName = templateName;
    }


}
